<template>
    
    <div class="shopCar-container">
        
       <div class='good-list'>
            <!-- 商品列表区域 -->
            <div class="mui-card" v-for="(item,index) in car" :key="item.id">
				<div class="mui-card-content">
					<div class="mui-card-content-inner">

						<mt-switch v-model="item.selected" @change="handleChange(item.id)">
                            
                        </mt-switch>

                        <img :src="item.pic" alt="">
                        <div class='info'>
                            <h2>{{item.topic}}</h2>
                            <p>
                                <span class='price'>￥{{item.price}}</span>
                                <numBox :num="item.count" :goodId="item.id"></numBox>
                                <a href="#" @click.prevent="delGoodsById(item.id,index)">删除</a>
                            </p>
                        </div>
                       
                    </div>
				</div>
                
			</div>
         </div>
            <!-- 结算区域 -->
            <div class="mui-card">
				<div class="mui-card-content">
					<div class="mui-card-content-inner jiesuan">
						
                        <div class='left'>
                            <p>总计(不含运费)</p>
                            <p>已勾选商品<span class='red'>{{$store.getters.getgoodCountAll.count}}</span>件,
                            总价<span class='red'>￥{{$store.getters.getgoodCountAll.amount}}</span></p>
                        </div>
                        <mt-button type='danger'>去结算</mt-button>
					</div>
				</div>
			</div>

       </div>
 
</template>

<script>

import numBox from '../news/GoodCars_num.vue';
export default {
    data () {
        return {
            car:this.$store.state.car      
        }
    },
    components: {
        numBox
    },
    methods: {
        delGoodsById(id,index){
            var obj={
                id,index
            }
            this.$store.commit("delgoodsById",obj);
        },
        handleChange(id){       
            this.$store.commit("handleNum",id)
        },

    },
    
}
</script>



<style lang="scss" scoped>
    .shopCar-container{
        overflow: hidden;
    }
    .shopCar-container{
        background-color: #eee;
        .good-list{
            img{
                width: 60px;
                height: 60px;
            }
        }
        .info{
            flex: 1;
            h2{
                font-size: 15px;
                white-space: nowrap;
                text-overflow: ellipsis;             
            }
            p{
                display: flex;
                align-items: center;
                justify-content: space-between;
                span{
                    color: #FF0036;
                    font-weight: bold;
                    font-size: 16px;
                }
                
            }
        }
    }
    .mui-card-content-inner{
        display: flex;
        justify-content: space-between;
    }
    .jiesuan{
        .left{
            letter-spacing: 2px;
            .red{
            color: red;
            font-size: 16px;
        }
        }
        display: flex;
        justify-content: space-around;
        align-items: center;
        
    }
</style>



